<template>
	<view class="content">
		<view class="logoBox">
			<image class="logoImg" src="/static/img/logo.png"></image>
			<!-- <image class="logoText" src="/static/img/logo-text.png"></image> -->
			<image class="logo-btm" src="/static/img/log-bg.png"></image>
		</view>
	</view>
</template>

<script>
	
	import {
		getOpenid,
	} from '@/api/common'
	export default {
		data() {
			return {

			};
		},
		onLoad() {
			uni.setStorageSync('userId', 1)
		},
		onShow() {
			this.initDataOpenId()
			
		},
		methods: {
			// 获取OpenId
			initDataOpenId() {
				let _that = this;
				uni.login({
					provider: 'weixin', //使用微信登录
					success: function(loginRes) {
						console.log(loginRes) 
						getOpenid(loginRes.code).then(res => {
							console.log(res)
							// return
							if (res.code == 200) {
								uni.setStorageSync('openId', res.data.openId)  
								uni.setStorageSync('userInfo', res.data)
								
								setTimeout(() => {
									uni.reLaunch({
										url: `/pages/index/index`
									})
								}, 2000)
								
							} else {
								this.$u.toast('网络错误')
								return
			
							}
						}).catch(err => {
							this.$u.toast('网络错误')
						})
			
			
					}
				})
			},
		}
	};
</script>

<style scoped lang="scss">
	.content {
		height: 100vh;
		overflow-y: auto;
		box-sizing: border-box;
		background: #DCF0F5;

		.logoBox {
			padding-top: 400rpx;

			.logoImg {
				width: 256rpx;
				height: 282rpx;
				display: block;
				margin: 0 auto;
			}

			.logoText {
				width: 359rpx;
				height: 79rpx;
				display: block;
				margin: 0 auto;
				margin-top: 30rpx;
			}
		}

		.logo-btm {
			width: 750rpx;
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			z-index: 1;
		}
	}
</style>